/**
 * 配置参考:
 * https://cli.vuejs.org/zh/config/
 */
const url = 'https://pigx.pig4cloud.com'
module.exports = {
    // lintOnSave 用做eslint代码检查 true代表警告但是可以编译 false代表不检查 error 代表必须要按照eslint编译
    lintOnSave: process.env.NODE_ENV !== 'production' ? 'error' : false,
    // 生产环境Map文件
    productionSourceMap: false,
    // 链式调用
    chainWebpack: (config) => {
        // console.log(config)
        // 忽略的打包文件
        config.externals({
            'vue': 'Vue',
            'vue-router': 'VueRouter',
            'vuex': 'Vuex',
            'axios': 'axios',
            'element-ui': 'ELEMENT',
        })
        const entry = config.entry('app')
        entry.add('babel-polyfill').end()
        entry.add('classlist-polyfill').end()
    },
    // 配置转发代理
    devServer: {
        disableHostCheck: true,
        port: 9527,
        proxy: {
            '/auth': {
                target: url,
                ws: true,
                pathRewrite: {
                    '^/auth': '/auth'
                }
            },
            '/admin': {
                target: url,
                ws: true,
                pathRewrite: {
                    '^/admin': '/admin'
                }
            },
            '/code': {
                target: url,
                ws: true,
                pathRewrite: {
                    '^/code': '/code'
                }
            },
            '/gen': {
                target: url,
                ws: true,
                pathRewrite: {
                    '^/gen': '/gen'
                }
            },
            '/daemon': {
                target: url,
                ws: true,
                pathRewrite: {
                    '^/daemon': '/daemon'
                }
            },
            '/job': {
              target: url,
              ws: true,
              pathRewrite: {
                '^/job': '/job'
              }
            },
            '/tx': {
                target: url,
                ws: true,
                pathRewrite: {
                    '^/tx': '/tx'
                }
            },
            '/act': {
                target: url,
                ws: true,
                pathRewrite: {
                    '^/act': '/act'
                }
            },
            '/actuator': {
              target: url,
              ws: true,
              pathRewrite: {
                '^/actuator': '/actuator'
              }
            },
            '/monitor': {
              target: url,
              ws: true,
              pathRewrite: {
                '^/monitor': '/monitor'
              }
            }
        }
    }
}
